﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    public class Enemy : Object
    {

        public int EnemyID;
        public int HP = 100;
        private int Armor = 100;
        private int Weapon = 0;

        public Enemy()
        {

        }
        public Enemy(int id,int X,int Y)
        {
            this.EnemyID = id;
            this.coord.X = X;
            this.coord.Y = Y;
        }

        ~Enemy()
        {

        }

        public override void Dispose()
        {

        }

        public void Attack()
        {

        }

        public void Go(SpriteBatch spriteBatch, Texture2D sprite, int frameSize, int frames, ref int enemyAnimState)
        {
            Rectangle source = new Rectangle(frameSize * frames, 0, frameSize, frameSize);
            Rectangle destination = new Rectangle((int)this.coord.X, (int)this.coord.Y, frameSize, frameSize);
            source.Y = frameSize * enemyAnimState;
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, destination, source, Color.White);
            spriteBatch.End();

        }

        public void Die()
        {

        }

        public override void ShowInfo(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, SpriteFont font)
        {
            Texture2D pixel = new Texture2D(graphicsDevice, 1, 1);
            Color[] colorData = {Color.White,};
            pixel.SetData<Color>(colorData);
            spriteBatch.Begin();
			if(HP>=81 && HP <=100)
            {
                spriteBatch.Draw(pixel, new Rectangle((int)coord.X-35, (int)coord.Y - 15, HP, 10), Color.Green);
            }
            else if (HP >= 61 && HP <= 80)
            {
                spriteBatch.Draw(pixel, new Rectangle((int)coord.X-35, (int)coord.Y - 15, HP,10), Color.Yellow);
            }
            else if (HP >= 41 && HP <= 60)
            {
                spriteBatch.Draw(pixel, new Rectangle((int)coord.X-35, (int)coord.Y - 15, HP,10), Color.Orange);
            }
            else if (HP >= 21 && HP <= 40)
            {
                spriteBatch.Draw(pixel, new Rectangle((int)coord.X-35, (int)coord.Y - 15, HP, 10), Color.Red);
            }
			else
            {
                spriteBatch.Draw(pixel, new Rectangle((int)coord.X-35, (int)coord.Y - 15, HP, 10), Color.DarkRed);
            }

            spriteBatch.Draw(pixel, new Rectangle((int)coord.X - 35, (int)coord.Y - 30, Armor, 10), Color.Gray);
            spriteBatch.End();
        }


    }
}
